• An MGLCircleAnnotationController is a controller that creates internally instances of an MGLShapeSource and MGLCicleStyleLayer to simplify the creation of runtime styling based annotations to the map.

    Create instances of MGLCircleStyleAnnotation and pass it to this controller to add circular shapes to an MGLMapView.

    Example

    func mapView(_ mapView: MGLMapView, didFinishLoading style: MGLStyle) {
       let circleAnnotationController = MGLCircleAnnotationController(mapView: self.mapView)
       let circle = MGLCircleStyleAnnotation(center: CLLocationCoordinate2D(latitude: 59.31, longitude: 18.06), radius: 3.0, color: .blue)
       circle.opacity = 0.5
       circleAnnotationController.add(circle)
    }
    
    See more

    Declaration

    Objective-C

    @interface MGLCircleAnnotationController : MGLAnnotationController

    Swift

    class MGLCircleAnnotationController : MGLAnnotationController
  • An MGLLineAnnotationController is a controller that creates internally instances of an MGLShapeSource and MGLLineStyleLayer to simplify the creation of runtime styling based annotations to the map.

    Create instances of MGLLineStyleAnnotation and pass it to this controller.

    Example

    func mapView(_ mapView: MGLMapView, didFinishLoading style: MGLStyle) {
       let lineAnnotationController = MGLLineAnnotationController(mapView: self.mapView)
    
       let lineCoordinates = [
           CLLocationCoordinate2D(latitude: 59, longitude: 18),
           CLLocationCoordinate2D(latitude: 60, longitude: 20)
       ]
    
       let line = MGLLineStyleAnnotation(coordinates: lineCoordinates, count: UInt(lineCoordinates.count))
       line.color = .purple
       lineAnnotationController.add(line)
    }
    
    See more

    Declaration

    Objective-C

    @interface MGLLineAnnotationController : MGLAnnotationController

    Swift

    class MGLLineAnnotationController : MGLAnnotationController
  • An MGLPolygonAnnotationController is a controller that creates internally instances of an MGLShapeSource and MGLFillStyleLayer to simplify the creation of runtime styling based annotations to the map.

    Create instances of MGLPolygonStyleAnnotation and pass it to this controller.

    Example

    func mapView(_ mapView: MGLMapView, didFinishLoading style: MGLStyle) {
       let polygonAnnotationController = MGLPolygonAnnotationController(mapView: self.mapView)
    
       let polygonCoordinates = [
           CLLocationCoordinate2DMake(59, 18),
           CLLocationCoordinate2DMake(62, 19),
           CLLocationCoordinate2DMake(54, 20),
           CLLocationCoordinate2DMake(59, 18)
       ]
    
       let polygon = MGLPolygonStyleAnnotation(coordinates: polygonCoordinates, count: UInt(polygonCoordinates.count))
       polygon.fillOutlineColor = .red
       polygonAnnotationController.add(polygon)
    }
    
    See more

    Declaration

    Objective-C

    @interface MGLPolygonAnnotationController : MGLAnnotationController

    Swift

    class MGLPolygonAnnotationController : MGLAnnotationController
  • An MGLSymbolAnnotationController is a controller that creates internally instances of an MGLShapeSource and MGLSymbolStyleLayer to simplify the creation of runtime styling based annotations to the map.

    Create instances of MGLSymbolStyleAnnotation and pass it to this controller.

    An image must be supplied to the map style’s sprite before being able to assign it to be the icon image of a symbol.

    Example

    func mapView(_ mapView: MGLMapView, didFinishLoading style: MGLStyle) {
       let attraction = UIImage(named: "attraction")
    
       if let styleImage = attraction {
           self.mapView.style?.setImage(styleImage, forName: "attraction")
       }
    
       let symbolAnnotationController = MGLSymbolAnnotationController(mapView: self.mapView)
    
       let symbol = MGLSymbolStyleAnnotation(coordinate: CLLocationCoordinate2DMake(59, 18));
       symbol.iconImageName = "attraction"
       symbol.text = "This is a cool place!"
       symbol.textFontSize = 16
       symbolAnnotationController.add(symbol)
    }
    
    See more

    Declaration

    Objective-C

    @interface MGLSymbolAnnotationController : MGLAnnotationController

    Swift

    class MGLSymbolAnnotationController : MGLAnnotationController